package main;


import com.kcbsdk.AFetchType;
import com.kcbsdk.CSvrTools;
import com.kcbsdk.EventHandler;
import com.kcbsdk.MyDomain.AListPage;
import com.kcbsdk.MyRankBa.AObbligatoList;
import com.kcbsdk.MyTools.AFileType;
import com.kcbsdk.MyTools.AIconType;
import com.kcbsdk.MyTools.AIconTypeList;
import com.kcbsdk.MyTools.ALocalInfoList;
import com.kcbsdk.MyTools.AUiPageName;
import com.kcbsdk.ZExtrApp;
import com.kcbsdk.cjmkcs;
import com.kcbsdk.wpapper;
import com.kcbsdk.MyTools.ACloudInfo;
import com.kcbsdk.MyTools.ACloudType;

import android.app.Activity;
import android.util.Log;
import android.widget.Toast;



public class MyTools implements wpapper {
    public CSvrTools mSvrTools;
    public Activity mActivity = null;
    public EventHandler mEventHandler = null;

    public AIconTypeList[] mAIconTypeList;
    private byte gSaveIconType[];
    private int g4SaveLocalInfo;
    private int g4EventLocalInfoList;

    public AListPage mListCloudInfo[];
    public ALocalInfoList[] mAObbligaList;
    public ALocalInfoList[] mARecordList;
    public ALocalInfoList[] mASearchObbList;
    public ALocalInfoList[] mASearchMusicList;
    public ALocalInfoList[] mASearchPhotoList;
    public ALocalInfoList[] mAReadySingList;
    public ALocalInfoList[] mADownFileList;
    public ALocalInfoList[] mAUpFileList;

    public String gsFetchPhotoFile;

    public ZExtrApp mZExtrApp[];
    public MyTools(){
        mSvrTools = new CSvrTools();
        mListCloudInfo = new AListPage[5];
        gSaveIconType = new byte[2];
    }
    public void startupExtrApp(){
        mZExtrApp = new ZExtrApp[8];
        cjmkcs.SET_MSG_CALLBACK(tTOOLS, new cjmkcs.MessageListener() {
            @Override
            public void messageReceived(int type, int g4Local_1, String gsLocal_1, String gsLocal_2) {
                ZExtrApp zExtrApp = new ZExtrApp();
                int g4Local_2 = type & 0x07;
                switch ((g4Local_1) >> 8 & 0x1f) {
                    case 0x01:
                        if (g4Local_2 == 1) {
                            gsLocal_2 = zExtrApp.ReqHttpsApp1(gsLocal_1);
                        }
                        else {
                            gsLocal_2 = zExtrApp.WriteToSvrApp1(gsLocal_1);
                        }
                        if (!"".equals(gsLocal_2)) {
                            //MSTRING("gsLocal_2 "+gsLocal_2);
                            cjmkcs.systemNetCommandDone(type, "ok", gsLocal_2.getBytes().length, gsLocal_2.getBytes());
                            return;
                        }
                        break;
                }
                cjmkcs.systemNetCommandDone(type, "error", g4Local_1, null);
            }
        });
    }

    public void pollingTimer(){
        if (mEventHandler != null && mActivity != null) {
            int methodType;
            for (int counter = 0; counter < 8; counter++){
                methodType = mSvrTools.getMethodType();
                if (methodType > 0){
                    String message = mSvrTools.getMethodMessage(methodType);
                    Log("mSvrTools.getMethodType " + String.format("%08X %s", methodType, message));
                    boolean isFail = ("ok".equals(message)) ? false : true;
                    if (!isFail){
                        if ((methodType & tFETCH_DBS_LIST) > 0) {
                            int number = (methodType>>16) & 0xff;
                            switch (methodType & 0x000000ff) {
                                case TOOLS_DBS_LIST_CLOUD: {
                                    int fileType = (methodType >> 8) & 0x0f;
                                    if (fileType < 5) {
                                        mListCloudInfo[fileType] = mSvrTools.methodCloudInfoDbs(methodType & 0x000000ff, fileType);
                                    }
                                }
                                break;
                                case TOOLS_DBS_LIST_ICON_TYPE:
                                    mAIconTypeList = mSvrTools.methodIconTypeListDbs(methodType, gSaveIconType[0]);
                                    gSaveIconType[1] = gSaveIconType[0];
                                    gSaveIconType[0] = 0;
                                break;
                                case TOOLS_DBS_LIST_LOCAL_KDB: {
                                    int uiPageName = (methodType >> 8) & 0x3f;
                                    switch (uiPageName){
                                        case TOOLS_UI_PAGE_DOWN_OBBLIG:			// 下载伴奏任务页面
                                            mAObbligaList = mSvrTools.eventLocalInfoList(methodType);
                                            break;
                                        case TOOLS_UI_PAGE_UP_RECORD:			// 上传录音文件任务页面
                                            mARecordList = mSvrTools.eventLocalInfoList(methodType);
                                            // mSvrTools.eventLoadingFile(TOOLS_UI_PAGE_UP_RECORD, mARecordList, g4RecordListQty);
                                            break;
                                        case TOOLS_UI_PAGE_LOCAL_OBBLIG:				// 查找手机伴奏页面
                                            mASearchObbList = mSvrTools.eventLocalInfoList(methodType);
                                            break;
                                        case TOOLS_UI_PAGE_LOCAL_MUSIC:					// 查找手机音乐页面
                                            mASearchMusicList = mSvrTools.eventLocalInfoList(methodType);
                                            break;
                                        case TOOLS_UI_PAGE_LOCAL_PHOTO:					// 查找手机图片页面
                                            mASearchPhotoList = mSvrTools.eventLocalInfoList(methodType);
                                            break;
                                        case TOOLS_UI_PAGE_LOCAL_ANY_FILE:				// 查找手机任意文件页面
                                            mARecordList = mSvrTools.eventLocalInfoList(methodType);
                                            break;
                                        case TOOLS_UI_PAGE_READY_SING:{				// 准备唱歌页面
//                                            MSTRING("TOOLS_UI_PAGE_READY_SING AA ");
                                            mAReadySingList = mSvrTools.eventLocalInfoList(methodType);
                                        }break;
                                        case TOOLS_UI_PAGE_DOWN_FILE:{				// 下载文件页面
                                            mADownFileList = mSvrTools.eventLocalInfoList(methodType);
                                            loadingLocalInfoItem(AUiPageName.PAGE_DOWN_FILE, mADownFileList[number].IndexID);	// 测试注意！！必须从返回列表之中找到ItemID！！！！
                                        }break;
                                        case TOOLS_UI_PAGE_UP_FILE:{				// 上传文件页面
                                            mAUpFileList = mSvrTools.eventLocalInfoList(methodType);
                                            loadingLocalInfoItem(AUiPageName.PAGE_UP_FILE, mAUpFileList[number].IndexID);	// 测试注意！！必须从返回列表之中找到ItemID！！！！
                                        }break;
                                    }
                                    g4EventLocalInfoList |= mSvrTools.getUiPageNameEvent(uiPageName);
                                    if (g4EventLocalInfoList > 0){
                                        mSvrTools.g4EventMethod |= TOOLS_EVENT_LOCAL_INFO_DBS;  // 制造一个事件用于UI
                                    }
//                                    Log(String.format("TOOLS_DBS_LIST_LOCAL_KDB A %d %08x", uiPageName, g4EventLocalInfoList));
                                    } break;
                            }
                        }
                    }
                    mEventHandler.onComplete(methodType, isFail, message);
                }
                else {
                    break;
                }
            }
            int newEvent = mSvrTools.pollingEvent();
            if (newEvent > 0){
                if ((newEvent & TOOLS_EVENT_LOCAL_INFO_DBS) > 0) {
                    cjmkcs.systemClearEvent(tTOOLS, TOOLS_EVENT_LOCAL_INFO_DBS, 0);
//                    MSTRING("TOOLS_EVENT_LOCAL_INFO_DBS A");
                    for (int counter = 0; counter < TOOLS_LOAD_TASK_RUN_MAX; counter++) {
                        int runType = cjmkcs.systemGetWpapperValue(wpTOOLS_LoadRunType | counter);
                        if (runType != 0) {    // 有
                            char uiPageName = (char) ((runType >> 8) & 0xff);    // [0]状态[1]uiPageName[2]fileType[3]cloudType
                            switch (uiPageName) {
                                case TOOLS_UI_PAGE_DOWN_OBBLIG:            // 下载伴奏任务页面
                                    mSvrTools.eventLoadingFile(uiPageName, mAObbligaList, mAObbligaList.length);
                                    break;
                                case TOOLS_UI_PAGE_UP_RECORD:            // 上传录音文件任务页面
                                    mSvrTools.eventLoadingFile(uiPageName, mARecordList, mARecordList.length);
                                    break;
//                                case TOOLS_UI_PAGE_LOCAL_OBBLIG:				// 查找手机伴奏页面
//                                    mSvrTools.eventLoadingFile(uiPageName, mARecordList, g4RecordListQty);
//                                    break;
//                                case TOOLS_UI_PAGE_LOCAL_MUSIC:					// 查找手机音乐页面
//                                    mSvrTools.eventLoadingFile(uiPageName, mARecordList, g4RecordListQty);
//                                    break;
//                                case TOOLS_UI_PAGE_LOCAL_PHOTO:					// 查找手机图片页面
//                                    mSvrTools.eventLoadingFile(uiPageName, mARecordList, g4RecordListQty);
//                                    break;
//                                case TOOLS_UI_PAGE_LOCAL_ANY_FILE:				// 查找手机任意文件页面
//                                    mSvrTools.eventLoadingFile(uiPageName, mARecordList, g4RecordListQty);
//                                    break;
                                case TOOLS_UI_PAGE_READY_SING:                    // 准备唱歌页面
//                                    MSTRING("TOOLS_UI_PAGE_READY_SING A "+counter);
                                    mSvrTools.eventLoadingFile(uiPageName, mAReadySingList, mAReadySingList.length);
//                                    MSTRING("TOOLS_UI_PAGE_READY_SING B");
                                    break;
                                case TOOLS_UI_PAGE_DOWN_FILE:                    // 准备唱歌页面
                                    mSvrTools.eventLoadingFile(uiPageName, mADownFileList, mADownFileList.length);
                                    break;
                                case TOOLS_UI_PAGE_UP_FILE:                    // 准备唱歌页面
                                    mSvrTools.eventLoadingFile(uiPageName, mAUpFileList, mAUpFileList.length);
                                    break;
                            }
                            g4EventLocalInfoList |= mSvrTools.getUiPageNameEvent(uiPageName);
                        }
                    }
                }
                if ((newEvent & TOOLS_EVENT_LOADING_FILE) > 0) {
                    MSTRING("TOOLS_EVENT_LOADING_FILE");
                    if (mAObbligaList != null && mAObbligaList.length > 0) {
                        g4EventLocalInfoList |= mSvrTools.eventLoadingFile(TOOLS_UI_PAGE_DOWN_OBBLIG, mAObbligaList, mAObbligaList.length);
                    }
                    if (mARecordList != null && mARecordList.length > 0) {
                        g4EventLocalInfoList |= mSvrTools.eventLoadingFile(TOOLS_UI_PAGE_UP_RECORD, mARecordList, mARecordList.length);
                    }
                    if (mAReadySingList != null && mAReadySingList.length > 0) {
                        g4EventLocalInfoList |= mSvrTools.eventLoadingFile(TOOLS_UI_PAGE_READY_SING, mAReadySingList, mAReadySingList.length);    //
                    }
                    if (mADownFileList != null && mADownFileList.length > 0) {
                        g4EventLocalInfoList |= mSvrTools.eventLoadingFile(TOOLS_UI_PAGE_DOWN_FILE, mADownFileList, mADownFileList.length);    //
                    }
                    if (mAUpFileList != null && mAUpFileList.length > 0) {
                        g4EventLocalInfoList |= mSvrTools.eventLoadingFile(TOOLS_UI_PAGE_UP_FILE, mAUpFileList, mAUpFileList.length);    //
                    }
                    cjmkcs.systemClearEvent(tTOOLS, TOOLS_EVENT_LOADING_FILE, 0);
                }
                if ((newEvent & TOOLS_EVENT_LOCAL_INFO_DBS) > 0) {
                    cjmkcs.systemClearEvent(tTOOLS, TOOLS_EVENT_LOCAL_INFO_DBS, 0);
                }
               // Log(String.format("mEventHandler.onComplete %08x", newEvent));
                mEventHandler.onComplete(0x00000000, false, "ok");
            }
        }
    }
    public void Log(String text){
        Log.d("MSYS", text);
    }
    public void Toast(String text){
        if (null != mActivity) {
            Toast.makeText(mActivity, text, Toast.LENGTH_SHORT).show();
        }
        Log.d("MSYS", text);
    }
    public void  setUiEventCallBack(Activity activity, EventHandler handler){
        mActivity = activity;
        mSvrTools.setMethodType();
        mEventHandler = handler;
        MREG.g4LastSelect = tTOOLS;
        Log(String.format("setUiEventCallBack A ", g4EventLocalInfoList));
        g4EventLocalInfoList = 0;
    }
    public void setDebugFlag(int debugFlag, int loadDelay){
        cjmkcs.systemSetDebugFlag(debugFlag, loadDelay);
    }
    public void wrMemString(String key, String text){
        mSvrTools.wrMemString(key, text);
    }
    public void wrMemValue(String key, int value){
        mSvrTools.wrMemValue(key, value);
    }
    public void wrMemBoolean(String key, boolean flag){
        mSvrTools.wrMemBoolean(key, flag);
    }
    public String rdMemString(String key){
        return mSvrTools.rdMemString(key);
    }
    public int rdMemValue(String key){
        return mSvrTools.rdMemValue(key);
    }
    public boolean rdMemBoolean(String key){
        return mSvrTools.rdMemBoolean(key);
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // 地区 省 市 区 榜名
    public String[] getAreaProvinceList(int retQty[]){
        String retList[] = new String[64];
        int counter = 0;
        for (; counter < 64; counter++){
            retList[counter] = cjmkcs.systemGetAreaData(0x01000000 | counter, "", "", "");
            if (retList[counter] == ""){
                break;
            }
        }
        retQty[0] = counter;
        return retList;
    }
    public String[] getAreaCityList(String province, int retQty[]){
        String retList[] = new String[64];
        int counter = 0;
        for (; counter < 64; counter++){
            retList[counter] = cjmkcs.systemGetAreaData(0x02000000 | counter, province, "", "");
            if (retList[counter] == ""){
                break;
            }
        }
        retQty[0] = counter;
        return retList;
    }
    public String[] getAreaRegions(String province, String city, int retQty[]){
        String retList[] = new String[64];
        int counter = 0;
        for (; counter < 64; counter++){
            retList[counter] = cjmkcs.systemGetAreaData(0x03000000 | counter, province, city, "");
            if (retList[counter] == ""){
                break;
            }
        }
        retQty[0] = counter;
        return retList;
    }
    public int getAreaRankData(String province, String city, String regions){
        if ("".equals(province) || "全国".equals(province)){
            return 0xffff;
        }
        String gsLocal_1 = cjmkcs.systemGetAreaData(0x08000000, province, city, regions);
        if (null != gsLocal_1 && !"".equals(gsLocal_1)) {
            return Integer.valueOf(gsLocal_1);
        }
        return 0;
    }
    public String getAreaDataProvince(int areaData){
        return cjmkcs.systemGetWpapperString(wpTOOLS_AreaDataProvince | areaData);
    }
    public String getAreaDataCity(int areaData){
        return cjmkcs.systemGetWpapperString(wpTOOLS_AreaDataCity | areaData);
    }
    public String getAreaDataRegions(int areaData){
        return cjmkcs.systemGetWpapperString(wpTOOLS_AreaDataRegions | areaData);
    }
    public String getAreaDataRankName(ACloudType aCloudType, int areaData){
        return cjmkcs.systemGetWpapperString(wpTOOLS_AreaDataRank | aCloudType.ordinal() | areaData);
    }
////////////////////////////////////////////////////////////////////////////////////////////////

    public void fetchHeadPhoto(int userID, int aImageSize, int dateTime){
        mSvrTools.fetchHeadPhoto(userID, aImageSize, dateTime);
    }
    public void fetchPhotoFile(int userID, int number, int dateTime){
        mSvrTools.downloadCloudFile(userID, number, 0, dateTime, "");
    }
    public void fetchCloudInfoDbs(AFetchType aFetchType, ACloudType aCloudType, int userID){
        mSvrTools.fetchCloudInfoList(aFetchType.ordinal(), aCloudType.ordinal(), userID);
    }
    public void fetchLoadingFileDbs(){
        mSvrTools.g4EventMethod |= TOOLS_EVENT_LOADING_DBS;
    }
    public void downloadCloudFile(ACloudType aCloudType, boolean IsVideo, int userID, int fileID){
        mSvrTools.downloadCloudFile(userID, fileID, aCloudType.ordinal(), IsVideo ? 1 : 0, "");
    }
    public void uploadPhotoFile(String loadingMark, String fileName){
        mSvrTools.uploadCloudFile(0, loadingMark, "", fileName);
    }
    public void uploadCloudFile(ACloudType aCloudType, String loadingMark, String mixText, String fileName){
        mSvrTools.uploadCloudFile(aCloudType.ordinal(), loadingMark, mixText, fileName);
    }
    public void deleteCloudFile(int userID, int fileID, ACloudType aCloudType) {
        mSvrTools.deleteCloudFile(userID, fileID, aCloudType.ordinal());
    }
    public void releaseCloudFile(int userID, int fileID, ACloudType aCloudType, int areaData, String intro) {
        mSvrTools.releaseCloudFile(userID, fileID, aCloudType.ordinal(), areaData, intro);
    }
    public String writeNetCommand(int type, String gsLocal_1, String gsLocal_2, String gsLocal_3) {
        return mSvrTools.writeNetCommand(type, gsLocal_1, gsLocal_2, gsLocal_3);
    }


    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public boolean isEventOnDestroy(){
        if ((mSvrTools.g4EventMethod & TOOLS_EVENT_ON_DESTROY) > 0){
            return true;
        }
        return false;
    }

    public ACloudInfo isEventCloudInfoDbs(ACloudType aCloudType){
        int eventType = mSvrTools.getNumberEvent(aCloudType.ordinal());
        if ((mSvrTools.g4EventMethod & eventType) > 0){
            mSvrTools.g4EventMethod &= eventType ^ 0xffffffff;
            return (ACloudInfo)mListCloudInfo[aCloudType.ordinal()].Result;
        }
        return null;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 本地队列及录音操作 //////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 获取使用的录音文件名（不包括扩展）
    public String getRecordFileName(ACloudType aCloudType){
        int g4Local_1 = (((int)TOOLS_UI_PAGE_UP_RECORD & 0x3f) << 8) | TOOLS_DBS_LIST_LOCAL_KDB;
        g4SaveLocalInfo = g4Local_1;
        return cjmkcs.systemGetWpapperString(wpTOOLS_RecordFileName | g4Local_1);
    }
    // 获取本地队列，包括PAGE_DOWN_OBB下载伴奏任务、PAGE_UP_RECORD上传录音任务
    public void fetchLocalInfoDbs(ACloudType aCloudType, AUiPageName aUiPageName){
        int g4Local_1 = (((int)aUiPageName.ordinal() & 0x3f) << 8) | TOOLS_DBS_LIST_LOCAL_KDB;
        int g4Local_2 = (((int)aCloudType.ordinal() & 0x3f) << 8) | TOOLS_CLOUD_FILE_AUDIO;
        g4SaveLocalInfo = g4Local_1;
        mSvrTools.optLocalInfoList(g4Local_1, g4Local_2, 0, 0, "", "", "", "");
    }
    // 删除本地队列，包括PAGE_DOWN_OBB下载伴奏任务、PAGE_UP_RECORD上传录音任务
    public void deleteLocalInfoItem(ACloudType aCloudType, AUiPageName aUiPageName, int ItemID){
        int g4Local_1 = (((int)aUiPageName.ordinal() & 0x3f) << 8) | TOOLS_DBS_LIST_LOCAL_KDB;
        int g4Local_2 = (((int)aCloudType.ordinal() & 0x3f) << 8) | TOOLS_CLOUD_FILE_AUDIO;
        g4SaveLocalInfo = g4Local_1;
        mSvrTools.optLocalInfoList(0x4000 | g4Local_1, g4Local_2, 0, 0, "", "", "", "");
    }
    // 从本地队列之中下载伴奏或者上传录音
    public void loadingLocalInfoItem(AUiPageName aUiPageName, int ItemID){
        int g4Local_1 = (((int)aUiPageName.ordinal() & 0x3f) << 8) | TOOLS_DBS_LIST_LOCAL_KDB;
        int g4Local_2 = ItemID & 0xffff;
        g4SaveLocalInfo = g4Local_1;
        cjmkcs.systemLoadingCloudFile(g4Local_1, g4Local_2, 0, 0, "", "", TOOLS_FETCH_DBS_LIST);
    }

    // 准备唱歌
    public void ReadyToSing(ACloudType aCloudType, AObbligatoList aObbligatoList){
        int g4Local_1 = (((int)TOOLS_UI_PAGE_READY_SING & 0x3f) << 8) | TOOLS_DBS_LIST_LOCAL_KDB;
        int g4Local_2 = (((int)aCloudType.ordinal() & 0x3f) << 8) | TOOLS_CLOUD_FILE_OBB_AUDIO;
//        if (aObbligatoList.IsVideo){
//            g4Local_2 = (g4Local_2 & 0x3f00) | TOOLS_CLOUD_FILE_OBB_VIDEO;
//            if (aObbligatoList.IsChorus){
//                g4Local_2 = (g4Local_2 & 0x3f00) | TOOLS_CLOUD_FILE_OBB_CHORUS_VIDEO;
//            }
//        }
//        else {
//            if (aObbligatoList.IsChorus){
//                g4Local_2 = (g4Local_2 & 0x3f00) | TOOLS_CLOUD_FILE_OBB_CHORUS_AUDIO;
//            }
//        }
        g4SaveLocalInfo = g4Local_1;
        String mixText = String.format("%d,", aObbligatoList.FileSize);
        mSvrTools.optLocalInfoList(0x8000 | g4Local_1, g4Local_2, aObbligatoList.MusicID0, aObbligatoList.MusicID1, aObbligatoList.SongName, aObbligatoList.ArtistName, mixText, aObbligatoList.IconFile);
    }


    // 增加下载伴奏的任务到本地队列之中
    public void AddObbligaToLocalInfo(ACloudType aCloudType, AObbligatoList aObbligatoList){
        int g4Local_1 = (((int)TOOLS_UI_PAGE_DOWN_OBBLIG & 0x3f) << 8) | TOOLS_DBS_LIST_LOCAL_KDB;
        int g4Local_2 = (((int)aCloudType.ordinal() & 0x3f) << 8) | TOOLS_CLOUD_FILE_OBB_AUDIO;
//        if (aObbligatoList.IsVideo){
//            g4Local_2 = (g4Local_2 & 0x3f00) | FILE_OBB_VIDEO;
//            if (aObbligatoList.IsChorus){
//                g4Local_2 = (g4Local_2 & 0x3f00) | FILE_OBB_CHORUS_VIDEO;
//            }
//        }
//        else {
//            if (aObbligatoList.IsChorus){
//                g4Local_2 = (g4Local_2 & 0x3f00) | FILE_OBB_CHORUS_AUDIO;
//            }
//        }
        g4SaveLocalInfo = g4Local_1;
        String mixText = String.format("%d,", aObbligatoList.FileSize);
        mSvrTools.optLocalInfoList(0x8000 | g4Local_1, g4Local_2, aObbligatoList.MusicID0, aObbligatoList.MusicID1, aObbligatoList.SongName, aObbligatoList.ArtistName, mixText, aObbligatoList.IconFile);
    }
    // 增加上传录音的任务到本地队列之中
    public void AddRecordToLocalInfo(ACloudType aCloudType, int MusicID0, int MusicID1, AFileType aFileType, String songName, String intro, int areaCode){
        String mixText = String.format("%d,", areaCode);
        int g4Local_1 = (((int)aCloudType.ordinal() & 0x3f) << 8) | TOOLS_UI_PAGE_UP_RECORD;
        g4SaveLocalInfo = g4Local_1;
        mSvrTools.optLocalInfoList(0x8000 | g4Local_1, MusicID0, MusicID1, (int)aFileType.ordinal(), songName, intro, mixText, "");
    }
    // 收到本地队列事件包括获取、删除、增加本地队列成功，及上传或者下载的消息用于百分比进度显示
    public boolean isEventLocalInfoDbs(ACloudType aCloudType, AUiPageName aUiPageName){
        //MSTRING("isEventLocalInfoDbs A "+g4EventLocalInfoList);
        if (g4EventLocalInfoList > 0){
            int g4Local_1 = mSvrTools.getUiPageNameEvent((int)aUiPageName.ordinal());
            //MSTRING(String.format("isEventLocalInfoDbs %d %08x", aUiPageName.ordinal(), g4Local_1));
            if ((g4EventLocalInfoList & g4Local_1) > 0){
                g4EventLocalInfoList &= g4Local_1 ^ 0xffffffff;
                if (g4EventLocalInfoList == 0) {
                    mSvrTools.g4EventMethod &= ~TOOLS_EVENT_LOCAL_INFO_DBS;
                }
                return true;
            }
        }
        return false;
    }
    // 查找手机里面的多媒体文件列表
    public void searchLocalSpecFileDbs(ACloudType aCloudType, AFetchType aFetchType, AUiPageName aUiPageName, String paths){	// 查找本地文件，获取指定文件列表
        int g4Local_1 = ((int)aFetchType.ordinal() << 14) |  ((int)aFetchType.ordinal() << 14) | ((0x3f & 0x3f) << 8) | aUiPageName.ordinal();
        g4Local_1 |= mSvrTools.g4Test_0x21 << 8;
        g4SaveLocalInfo = g4Local_1;
        mSvrTools.optLocalInfoList(0xc000 | g4Local_1, 0, 0, 0, paths, "", "", "");
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 获取图标列表操作 /////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 获取图标列表，包括ICON_ACCOUNT，ICON_OBB_CLASS伴奏分类，ICON_OBB_ARTIST伴奏歌手，
    public void fetchIconTypeList(ACloudType aCloudType, AIconType aIconType){		// 获取图标列表
        if (gSaveIconType[0] == 0){								// 上次已经完成
            gSaveIconType[0] = (byte)(0x40 | aIconType.ordinal());
//            mSvrTools.fetchIconTypeList(gSaveIconType[0] & 0x3f, AFetchType.LIST_NORMAL.ordinal(), aIconType.ordinal(), "");
            mSvrTools.fetchIconTypeList(aCloudType.ordinal(), AFetchType.LIST_FRESHEN.ordinal(), aIconType.ordinal(), "");
        }
    }
    public void fetchIconTypeList(ACloudType aCloudType, AIconType aIconType, String name){		// 获取图标列表
        if (gSaveIconType[0] == 0){								// 上次已经完成
            gSaveIconType[0] = (byte)(0x40 | aIconType.ordinal());
            mSvrTools.fetchIconTypeList((int)aCloudType.ordinal(), (int)AFetchType.LIST_FRESHEN.ordinal(), (int)aIconType.ordinal(), name);
        }
    }
    public boolean isSucessIconTypeListDbs(int methodType, AIconType aIconType){
        if ((methodType & 0xff) == TOOLS_DBS_LIST_ICON_TYPE){
            if ((gSaveIconType[1] & 0x3f) == (char)aIconType.ordinal()){
                return true;
            }
        }
        return false;
    }

    public void MSTRING(String text) {
        Log.d("MSYS", text);
    }

}
